package com.justnow.learnclassinstance.demo;

/**
 * @author justnow
 * Created on 2020-11-24
 * Description
 */
public class Test {
    public static void main(String[] args) {
        System.out.println("测试classloader方法");
        testClassLoader();
        System.out.println("-------------------");
        System.out.println("测试Class.forName方法");
        testForName();
    }
    public static void testClassLoader(){
        ClassLoader loader = ClassLoader.getSystemClassLoader();
        Class<?> lineClass = null;
        try {
            lineClass = loader.loadClass("com.justnow.learnclassinstance.demo.Line");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
    public static void testForName() {
        try {
            Class<?> lineClass = Class.forName("com.justnow.learnclassinstance.demo.Line");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
}
